//
//  main.c
//  指针和函数(函数作为参数)
//
//  Created by szcq on 2021/5/7.
//

#include <stdio.h>

int sum(int v1, int v2)
{
    return v1 + v2;
}

int minus(int v1, int v2)
{
    return v1 - v2;
}


/// action方法
/// @param v1 V1
/// @param v2 V2
/// @param function 函数指针
int action(int v1,int v2,int(*function)(int,int)) {
    int result = function(v1,v2);
    return result;
}

int main(int argc, const char * argv[]) {
    
    int(*function_1)(int,int) = sum;
    int(*function_2)(int,int) = minus;
    
//    int sum_v = action(10, 20, function_1);
//    int minus_v = action(20, 10, function_2);
    int sum_v = action(10, 20, sum);
    int minus_v = action(20, 10, minus);
    printf("sum_v = %d,\nminus_v = %d\n",sum_v,minus_v);
    
    return 0;
}
